//
// Created by 紫霄 on 2020/4/21.
//
//第一个只出现一次的字符串

#ifndef LEETCODE_50_H
#define LEETCODE_50_H
#include <string>
#include <unordered_map>
using namespace std;
class Solution {
public:
  char firstUniqChar(string s) {
    char ans = ' ';
    if (!s.empty()) {
      unordered_map<char, int> temp;
      for (int i = 0; i < s.size(); ++i) {
        ++temp[s[i]];
      }
      for (int i = 0; i < s.size(); ++i) {
        if (temp[s[i]] == 1) {
          return s[i];
        }
      }
    }
    return ans;
  }
};
#endif // LEETCODE_50_H
